using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using EnvDTE;

namespace DoxyComment
{
	public partial class OptionsGeneralPage : UserControl,EnvDTE.IDTToolsOptionsPage
	{
		public OptionsGeneralPage()
		{
			InitializeComponent();

			// Set the property used for text in drop list
			activeProviderDropDown.DisplayMember = "DisplayName";

			// Get provider names for drop-down list
			foreach (IProviderInfo pi in ConfigHelper.Instance.ProviderTypes)
			{
				activeProviderDropDown.Items.Add(pi);
			}
		}

		#region IDTToolsOptionsPage implementation

		public void GetProperties(ref object propertiesObject)
		{
			propertiesObject = null;
		}

		public void OnAfterCreated(EnvDTE.DTE DTEObject)
		{
			ResetUI();
		}

		public void OnCancel()
		{
			ResetUI();
		}

		public void OnHelp()
		{
		}

		public void OnOK()
		{
			ConfigHelper cfg = ConfigHelper.Instance;

			// Save new options back to registry object
			cfg.IndentCommentBlocks = indentCommentCheck.Checked;
			cfg.InsertAtDefinition = insertAtDefinitionCheck.Checked;
			cfg.ActiveProviderType = (IProviderInfo)activeProviderDropDown.SelectedItem;
		}

		private void ResetUI()
		{
			ConfigHelper cfg = ConfigHelper.Instance;

			indentCommentCheck.Checked = cfg.IndentCommentBlocks;
			insertAtDefinitionCheck.Checked = cfg.InsertAtDefinition;
			activeProviderDropDown.SelectedItem = cfg.ActiveProviderType;
		}

		#endregion
	}
}
